<?php
echo '
<div class="ContentInfo Top">
	<h1>
		'.$this->Context->PageTitle.'
	</h1>
	'.$this->PageJump.'
	<div class="PageInfo">
		<p>'.($PageDetails == '' ? $this->Context->GetDefinition('NoPrivateMessagesFound') : $PageDetails).'</p>
		'.$PageList.'
	</div>
</div>
<div id="ContentBody">
	<table border="0" cellpadding="0" cellspacing="0" class="Grid" id="MailBox">
	<tbody>
';

$Discussion = $this->Context->ObjectFactory->NewContextObject($this->Context, 'Discussion');
$FirstRow = 1;
$MessageList = '';
$Alternate = 0;
while ($Row = $this->Context->Database->GetRow($this->DiscussionData)) {
	$Discussion->Clear();
	$Discussion->GetPropertiesFromDataSet($Row, $this->Context->Configuration);
	$Discussion->FormatPropertiesForDisplay();

	$Body = str_replace("<br />", "&nbsp;", $Row['Body']);
	$Subject = SliceString($Discussion->Name .'<em> - '. $Body .'</em>', 100);
	$ItemUrl = GetUrl($this->Context->Configuration, 'extension.php', '', 'DiscussionID', $Discussion->DiscussionID, '', 'PostBackAction=PrivateMessages&View=Message');

	$MessageList .= '
	<tr class="MailBoxItem '.($Discussion->NewComments ? 'New' : 'Red').($Alternate ? ' Alternate' : '').'">';
	if ($Discussion->WhisperUsername !== $this->Context->Session->User->Name) {
		$MessageList .= '
		<td class="MailBoxTo"><a href="'.GetUrl($this->Context->Configuration, 'account.php', '', 'u', $Discussion->WhisperUserID).'">'.$Discussion->WhisperUsername.'</a> '.($Discussion->CountComments > 1 ? ' ('.$Discussion->CountComments.')' : '' ).'</td>';
	} else {
		$MessageList .= '
		<td class="MailBoxFrom"><a href="'.GetUrl($this->Context->Configuration, 'account.php', '', 'u', $Discussion->AuthUserID).'">'.$Discussion->AuthUsername.'</a> '.($Discussion->CountComments > 1 ? ' ('.$Discussion->CountComments.')' : '' ).'</td>';
	}
	$MessageList .= '
		<td class="MailBoxSubject"><a href="'.$ItemUrl.'">'.$Subject.'</a></td>
		<td class="MailBoxDate">'.TimeDiff($this->Context, $Discussion->DateCreated).'</td>
	</tr>
	';
	
	$FirstRow = 0;
	$Alternate = FlipBool($Alternate);
}
echo $MessageList.'
	</tbody>
	</table>
</div>';
if ($this->DiscussionDataCount > 0) {
   echo '<div class="ContentInfo Bottom">
		<div class="PageInfo">
			<p>'.$pl->GetPageDetails($this->Context).'</p>
			'.$PageList.'
		</div>
		<a id="TopOfPage" href="'.GetRequestUri().'#pgtop">'.$this->Context->GetDefinition('TopOfPage').'</a>
	</div>';
}
?>